#include <stdio.h>
#include <windows.h>
#include "code.h"

int main() {

    SetConsoleOutputCP(CP_UTF8);

    const char message[] = "A";
    double volts[11];
    int volts_size = 11;
    int encoded_size = rs232c_encode(volts, volts_size, message, 1);
    if (encoded_size == -1) {
        printf("编码失败：缓冲区不足\n");
        return 1;
    }

    char decoded_message[2];
    int decoded_size = rs232c_decode(decoded_message, 2, volts, volts_size);
    if (decoded_size == -1) {
        printf("解码失败\n");
        return 1;
    }
    decoded_message[decoded_size] = '\0';
    printf("解码消息: %s\n", decoded_message);
    return 0;
}